package com.atguigu.springcloud.alibaba.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.atguigu.springcloud.alibaba.GlobalBlockHandler.OrderBlockHandler;
import com.atguigu.springcloud.alibaba.service.OrderService;
import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Order;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author lixiaolong
 * @date 2020-02-26 15:24
 */
@RestController
public class OrderController {
    @Resource
    private OrderService orderService;


    @GetMapping("/order/create")
    @SentinelResource(value = "order/create", blockHandlerClass = OrderBlockHandler.class, blockHandler = "handlerException")
    public CommonResult create(Order order) {
        orderService.create(order);
        return new CommonResult(200, "订单交易完成");
    }



}
